package com.vg.view;

import vg.com.chatonline.activity.R;
import vg.com.frame.user_frame;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import br.com.dina.ui.widget.UITableView_User;

public class user_left extends Fragment {
	private UITableView_User tableView;
	private static Fragment instace = null;

	public user_left() {
		// TODO Auto-generated constructor stub
	}

	/* Kiem tra neu = null thi khoi tai lai Frame,neu k thi k can phai khoi tao */
	public static Fragment newinstance() {
		if (instace == null)
			instace = new user_left();

		return instace;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View v = inflater.inflate(R.layout.user, null);
		user_frame post = (user_frame) v.findViewById(R.id.layout_user);
		post.fillData(
				"Tuan",
				"http://k14.vcmedia.vn/k:thumb_w/600/UZ6rra687dP37yYjwT3phKBWfbD/Image/2013/01/van-navy-cbe45/hot-girl-ha-thanh-dien-style-doi-lap-don-me-ma.jpg");
		tableView = (UITableView_User) v.findViewById(R.id.listview_user);
		createList();
		tableView.commit(R.layout.list_item_user, R.layout.list_item_user,
				R.layout.list_item_user);
		return v;
	}

	private void createList() {
		CustomClickListener listener = new CustomClickListener();
		tableView.setClickListener(listener);
		tableView.addBasicItem(R.drawable.us_account, "Trang cá nhân", "");
		tableView.addBasicItem(R.drawable.us_edit, "Chỉnh Sửa Thông Tin", "");
		tableView.addBasicItem(R.drawable.us_logout, "Thay đổi tài khoản", "");
		tableView.addBasicItem(R.drawable.us_product, "Sản Phẩm", "");
		tableView.addBasicItem(R.drawable.us_close, "Thoát Ứng Dụng", "");

	}

	private class CustomClickListener implements
			br.com.dina.ui.widget.UITableView_User.ClickListener {

		public void onClick(int index) {
			if (index == 0) {
				Intent i = new Intent(getActivity(), info_User.class);
				startActivity(i);
			} else if (index == 1) {
				Intent i = new Intent(getActivity(), edit_infoUser.class);
				startActivity(i);
			} else if (index == 2) {
				getActivity().finish();
				Intent i = new Intent(getActivity(), login_index.class);
				startActivity(i);
			} else if (index == 3) {
				Intent i = new Intent(getActivity(), info_User.class);
				startActivity(i);
			} else if (index == 4) {
				getActivity().finish();
			}

		}

	}
}
